package com.gml.design.factory.optimize;

import com.gml.design.factory.optimize.impl.CouponCommodity;

import java.util.HashMap;

public class Test {


    /**
     * 将各种类型的礼品抽象化，统一交由工厂管理创建对应的实现类
     * 由工厂派发，然后去真实发放
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        StoreFactory storeFactory = new StoreFactory();

        // 1. 优惠券
        ICommodity commodityService_1 = storeFactory.getCommodity(1);
        commodityService_1.sendCommodity("10001", "EGM1023938910232121323432", "791098764902132", null);

        // 2. 实物商品
        ICommodity commodityService_2 = storeFactory.getCommodity(2);
        commodityService_2.sendCommodity("10001", "9820198721311", "1023000020112221113", new HashMap<String, String>() {{
            put("consigneeUserName", "谢飞机");
            put("consigneeUserPhone", "15200292123");
            put("consigneeUserAddress", "吉林省.长春市.双阳区.XX街道.檀溪苑小区.#18-2109");
        }});

        // 3. 第三方兑换卡(模拟爱奇艺)
        ICommodity commodityService_3 = storeFactory.getCommodity(3);
        commodityService_3.sendCommodity("10001", "AQY1xjkUodl8LO975GdfrYUio", null, null);


        StoreFactory storeFactory2 = new StoreFactory();
        // 1. 优惠券
        ICommodity commodityService = storeFactory2.getCommodity(CouponCommodity.class);
        commodityService.sendCommodity("10001", "EGM1023938910232121323432", "791098764902132", null);

    }

}
